local view = require 'views.view'

---@class single_child_view: view
---@field child view
local single_child_view = view:new_view_type()

---@class single_child_view.renderer: view.renderer
---@field child_renderer view.renderer
single_child_view.renderer = view.renderer:new_renderer_type()

function single_child_view:create_renderer_instance()
    return self:set_renderer_prototype {
        child_renderer = self.child:create_renderer_instance()
    }
end

function single_child_view.renderer:layout(constraints, view)
    return self.child_renderer:layout(constraints, view.child)
end

function single_child_view.renderer:render(render_rect, view)
    self.child_renderer:render(render_rect, view.child)
end

function single_child_view.renderer:destroy()
    self.child_renderer:destroy()
end

return single_child_view
